#!/usr/bin/perl -w

use Bio::SearchIO;

my $searchio = Bio::SearchIO->new(-format => 'blast', -file => $ARGV[0]);

while (my $result = $searchio->next_result){
    while (my $hit = $result->next_hit){
        while (my $hsp = $hit->next_hsp){
            my $percent = sprintf("%.2f", $hsp->percent_identity);
            print $result->query_name, "\t", $hit->name, "\t", $hsp->start, "\t", $hsp->end, "\t", $percent, "\t", $hsp->evalue, "\t", $hsp->bits, "\t", $hit->description(), "\n";
        }
    }
}
